package org.example.familyterminalms.controller;

import lombok.RequiredArgsConstructor;
import org.example.familyterminalms.service.ModelServiceImpl;
import org.springframework.web.bind.annotation.*;
import org.example.familyterminalms.entity.Model;

import java.util.List;
@RestController
@RequestMapping("/models")
@RequiredArgsConstructor
public class ModelController {

    private final ModelServiceImpl modelService;

    @GetMapping
    public List<Model> getAllModels() {
        return modelService.getAllModels();
    }

    @GetMapping("/{id}")
    public Model getModelById(@PathVariable Long id) {
        return modelService.getModelById(id);
    }

    @PostMapping
    public void addModel(@RequestBody Model model) {
        modelService.addModel(model);
    }

    @PutMapping("/{id}")
    public void updateModel(@PathVariable Long id, @RequestBody Model model) {
        model.setId(id);
        modelService.updateModel(model);
    }

    @DeleteMapping("/{id}")
    public void deleteModel(@PathVariable Long id) {
        modelService.deleteModelById(id);
    }
}